/**
 * props: {
 *  fileList: Array,
 *  handleSuccess: Function
 *  handleRemove: Function
 * }
 */
import React, { Component } from 'react'
import {Upload, Message, Button} from 'element-react'

class ImgUpload extends Component {
  constructor(props) {
    super(props)
    this.state = {}
  }
  render () {
    return (
      <Upload
        className="upload-demo"
        action="http://tft-dev/api3/upload/file"
        onSuccess={(response, file, fileList) => this.props.handleSuccess(response, file, fileList)}
        onError={(err, file, fileList) => { Message.error('提交失败') }}
        onRemove={(file, fileList) => this.props.handleRemove && this.props.handleRemove(file, fileList)}
        listType="picture"
        fileList={this.props.fileList}
      >
        <Button type="primary">点击上传</Button>
      </Upload>
    )
  }
}
export default ImgUpload